<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Attractions\Commerce\Request\Commerce_order_product;

use Hyperf\Validation\Request\FormRequest;

/**
 * 订单商品验证数据类
 */
class CommerceOrderProductRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            //商品名称 验证
            'commodity_name' => 'required',
            //数量 验证
            'quantity' => 'required',
            //单价 验证
            'price' => 'required',
            //折扣 验证
            'discount' => 'required',
            //总价 验证
            'total_price' => 'required',

        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'order_id' => '订单号',
            'commodity_id' => '商品ID',
            'commodity_name' => '商品名称',
            'quantity' => '数量',
            'price' => '单价',
            'discount' => '折扣',
            'total_price' => '总价',

        ];
    }

public function messages(): array
{
    return [
            'order_id.required' => '必填订单号',
            'commodity_id.required' => '必填商品ID',
            'commodity_name.required' => '必填商品名称',
            'quantity.required' => '必填数量',
            'price.required' => '必填单价',
            'discount.required' => '必填折扣',
            'total_price.required' => '必填总价',

    ];
}
}